<template>
	<view class="content">
		<nav-bar title="详情" />
		<view class="add-con">
			<view class="margin">
				<view class="cu-card">
					<view class="card-title">作业信息</view>
					<u-cell-group>
						<u-cell title="课程名" :value="detailDatas.kecheng"></u-cell>
						<u-cell title="章节" :value="detailDatas.zhangjie"></u-cell>
						<u-cell title="作业" :value="detailDatas.zuoye"></u-cell>
						<u-cell title="工号" :value="detailDatas.gonghao"></u-cell>
					</u-cell-group>
				</view>
				<u-gap height="15"/>
				<view class="cu-card">
					<view class="card-title">完成作业信息</view>
					<u-cell-group>
						<u-cell v-if="detailDatas.defen" title="得分" :value="detailDatas.defen"></u-cell>
						<u-cell title="作业">
							<template #label>
								<view class="padding-top-sm">
									<upload-file v-model="formData.tijiaozuoye"></upload-file>
								</view>
								
							</template>
						</u-cell>
						<u-cell title="学号" :value="formData.xuehao"/>
						<u-cell title="姓名">
							<template #value>
								<u-input v-model="formData.xingming" inputAlign="right" border="none" placeholder="请输入姓名"/>
							</template>
						</u-cell>
					</u-cell-group>
					<u-cell title="完成日期">
							<template #value>
								<select-picker pickerType="time" @pickerChange="pickerChange($event,'wanchengriqi')" timeType="date">
									<view class="flex justify-end">
										<text style="text-align:right" v-if="formData.wanchengriqi">{{formData.wanchengriqi}}</text>
										<text v-else class="textInfo">请选择</text>
										<u-icon name="arrow-right" />
									</view>
								</select-picker>
							</template>
						</u-cell>
					</u-cell-group>
				</view>
				<view class="padding-tb flex align-center">
					<u-button type="primary" text="修改" @click="formSubmit"></u-button>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {submitMinxins, detailMinxins } from '@/common/mixins/mixins.js'
	import uploadFile from '@/components/uploadFile.vue'
	import SelectPicker from '@/components/selectPicker.vue'
	export default {
		name: 'myZuoyeDetail',
		desc:'详情',
		components: {
			uploadFile,SelectPicker
		},
		mixins: [detailMinxins,submitMinxins],
		data() {
			return {
				detailDatas:{},
				userInfo: this.$store.state.vuex_user, //用户信息
				formData: {},
				urlapi: {
					detail:'/zuoyetijiao',//编辑接口
					edit:'/zuoyetijiao'
				},
				isAdd:false,//
				rule: [{
					name: "tijiaozuoye",
					checkType: "notnull",
					errorMsg: "请上传作业"
				}, {
					name: "wanchengriqi",
					checkType: "notnull",
					errorMsg: "请选择完成日期"
				}, ],
			}
		},
		onLoad(option) {
			this.initDatas(option.id)
		},
		methods:{
			initDatas(id){
				//存在参数 id ，可编辑
				let that =this
				if(id){
					that.getDetailData(id).then(res=>{
						that.detailDatas =res
						that.formData =res
					}) //获取详情
				}
			},
			pickerChange(e,label){
				this.$set(this.formData,label,uni.$u.timeFormat(e, 'yyyy-mm-dd'))
			}
		}
	}
</script>

<style lang="scss" scoped>
</style>